<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="https://cdn.staticfile.org/jquery/1.10.2/jquery.min.js"></script>
    <script src="https://cdn.staticfile.org/echarts/4.3.0/echarts.min.js"></script>
    <script type="text/javascript">


        $(function () {//页面加载结束

            var myChart = echarts.init(document.getElementById('main'));

            var option = {
                title: {
                    text: '现有确诊病例数，排除治愈、死亡',
                    subtext: '',
                    x: 'center'
                },
                tooltip: {
                    trigger: 'item',
                    formatter: "{a} <br/>{b} : {c} ({d}%)"
                },
                legend: {
                    orient: 'vertical',
                    left: 'left',
                },
                series: [
                    {
                        name: '访问来源',
                        type: 'pie',
                        radius: '55%',
                        center: ['50%', '60%'],
                        data: [],
                        itemStyle: {
                            emphasis: {
                                shadowBlur: 10,
                                shadowOffsetX: 0,
                                shadowColor: 'rgba(0, 0, 0, 0.5)'
                            }
                        }
                    }
                ]
            };

            // 使用刚指定的配置项和数据显示图表。
            myChart.setOption(option);

            //发送请求
            var  url = "http://localhost:8080/project1/test3"
            var paramter = ""
            var func =function(data){

                for (var i =0;i < data.length;i++){
                    option.series[0].data.push({
                        "value": data[i].nums, "name": data[i].name
                    })
                }
                myChart.setOption(option);
            }
            var type="json"
            $.get(url,paramter,func,type);

        })
    </script>
</head>
<body>
    <div id="main" style="width: 600px;height:400px;"></div>
</body>
</html>